package com.zlsy.learning.leetcode.arraycorrelation.array1342;

/**
 * @author zhouliang
 * @date 2020/06/25
 **/
public class NumberOfSteps {

    public static int numberOfSteps(int num) {
        int count = 0;

        while (num != 0) {
            if ((num & 1) == 1) {
                num = num - 1;
            } else {
                num = num / 2;
            }
            count++;
        }
        return count;
    }

    public static void main(String[] args) {
        int i = numberOfSteps(321);
        System.err.println(i);
    }
}
